package game.manager 
{
	import com.adobe.MD5;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.URLRequestMethod;
	import flash.net.URLVariables;
	/**
	 * ...
	 * @author gcxk721
	 */
	public class StatisticsManager 
	{
		
		private static var _errorURL:String = "/api/zxy/log_error.php";
        private static var _uploadURL:String = "/api/zxy/register.php";

        public static function sendError(step : int):void
		{
            var accname : String = ConfigManager.parameters.accname;
            var request : URLRequest = new URLRequest(_errorURL);
            var urlLoader : URLLoader = new URLLoader();
            urlLoader.addEventListener(Event.COMPLETE, errorComplete);
            with ({}) {
                {}.loggerioerror = function (e:IOErrorEvent):void{
                };
            };
            urlLoader.addEventListener(IOErrorEvent.IO_ERROR, function (e:IOErrorEvent):void{
            });
            var variables:URLVariables = new URLVariables();
            variables.time = int((new Date().time / 1000));
            variables.step = step;
            variables.ticket = MD5.GetMD5(String(variables.step) + String(variables.time) + "ZXY@jieyou.com#%^!@");
            request.data = variables;
            request.method = URLRequestMethod.POST;
            urlLoader.load(request);
        }
		
        private static function errorComplete(_arg1:Event):void 
		{
			
        }
        public static function send(step : int):void{
            var accname:String = ConfigManager.parameters.accname;
            var request:URLRequest = new URLRequest(_uploadURL);
            var urlLoader:URLLoader = new URLLoader();
            with ({}) {
                {}.loggerComplete = function (e:Event):void{
                };
            };
            urlLoader.addEventListener(Event.COMPLETE, function (e:Event):void{
            });
            with ({}) {
                {}.loggerioerror = function (e:IOErrorEvent):void{
                };
            };
            urlLoader.addEventListener(IOErrorEvent.IO_ERROR, function (e:IOErrorEvent):void{
            });
            var variables:URLVariables = new URLVariables();
            variables.accname = accname;
            variables.time = int((new Date().time / 1000));
            variables.step = step;
            variables.ticket = MD5.GetMD5(String(variables.accname) + String(variables.time) + String(step) + "ZXY@jieyou.com#%^!@");
            request.data = variables;
            request.method = URLRequestMethod.POST;
            urlLoader.load(request);
        }
		
	}

}